package by.uvaga.wind;

import java.io.FileOutputStream;

import by.uvaga.wind.AdvColorPickerDialog.OnColorChangedListener;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;

public class OptionsActivity extends Activity implements OnColorChangedListener{

	private SeekBar seekBar;
	private Button buttonsave;
	protected OptionsActivity optionsActivity = this;
	
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated constructor stub
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.options);
		
		seekBar = (SeekBar) findViewById(R.id.seeWidthBar);
		buttonsave = (Button) findViewById(R.id.savebutton);
        buttonsave.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Perform action on click
            	PaintView.strokeWidth = seekBar.getProgress();
        		Log.v("OptionsActivity", "set strokeWidth to "+seekBar.getProgress());
            	Intent intent = new Intent(getApplicationContext(), GraphicsActivity.class);
        		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        		startActivity(intent);
        		Log.v("OptionsActivity", "Activity GraphicsActivity Started........");
            }
        });
        
        seekBar.setMax((int)PaintView.MAX_STROKEWIDTH);
        seekBar.setProgress((int)PaintView.strokeWidth);
        seekBar.refreshDrawableState();
	}
	
	public void changeColor(View view) {
		AdvColorPickerDialog dlgColor = new AdvColorPickerDialog(view.getContext(), this, Color.WHITE);
		dlgColor.show();
	}
	
	@Override
	public void colorChanged(int color) {
		// TODO Auto-generated method stub
		PaintView.color = color;
	}

}
